<script setup>
import { onMounted, ref, watch } from 'vue';
import { useDepartmentSelectStore } from '../../store/departmentSelect';
import department from '../../api/department';
import { useAddDepartmentStore } from '../../store/addDepartment';
const addDepartmentStore = useAddDepartmentStore();
const departmentSelectStore = useDepartmentSelectStore();
// 配置树形组件属性
const treeProps = {
    value: 'value',
    label: 'label',
    children: 'children'
}
onMounted(async () => {
    await department.getDepartmentSelect().then((res) => {
        departmentSelectStore.setDepartmentSelect(res.data.data);
    }).catch((err) => {
        console.log(err);
    });
});
</script>
<template>
    <el-tree-select :disabled="departmentSelectStore.disabled"
        v-if="(addDepartmentStore.department.parentId !== addDepartmentStore.department.id) || addDepartmentStore.department.id === ''"
        :props="treeProps" node-key="value" v-model="addDepartmentStore.department.parentId" check-strictly clearable
        :data="departmentSelectStore.departmentSelect" :render-after-expand="false" />
</template>
<style scoped></style>